/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Admin;

import Login.MySqlConnector;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Bharath
 */
public class ManageMembersDao {

    Connection con;
    PreparedStatement ps;
    MySqlConnector ms = new MySqlConnector();
    String q = null;
    boolean b1;
    //RegistrationBean rb = new RegistrationBean();
//---------------------------- Activate the user -----------------------------------

    public boolean Activate(String rcheck) {
        System.out.print("activate method --------------- > ");
        try {
            con = ms.Connect();
            q = "update registration set status = 1 where memberid = '" + rcheck + "';";
            System.out.print("query=" + q);
            ps = con.prepareStatement(q);
            int rs = ps.executeUpdate();
            System.out.print("Activate method --------------- > " + rs);
            if (rs == 1) {
                b1 = true;
            } else {
                b1 = false;
            }
        } catch (Exception e) {
            System.out.print("Exception in manage dao is " + e);
        }
        System.out.println("b1=" + b1);
        return b1;
    }
    public boolean Delete_Member(String rcheck) throws Exception
    {
    System.out.println("In delete member method ");
    System.out.println("rcheck value in delete member is "+rcheck);
    try {
            con = ms.Connect();
            q = "delete from registration where memberid = '"+rcheck+"' ;";
            ps = con.prepareStatement(q);
            int i= ps.executeUpdate();
            if (i == 1)
            {
                System.out.print("in If i ==1 condition delete member method");
                return true;
            }
            else
                return false;
        } catch (SQLException ex) {
            Logger.getLogger(ManageMembersDao.class.getName()).log(Level.SEVERE, null, ex);
        }
    return false ;
    }
}
